package com.coder520.user.controller;

import com.coder520.user.entity.User;
import com.coder520.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * @Author 高鑫【gx_wanmei@163.com】
 * Created by 2017-6-19.2:16
 */
@Controller
@RequestMapping("user")
public class UserController {
    @Autowired
    private UserService userService;
    @RequestMapping("/home")
    public String home()
    {
        return "home";
    }
    /**
     *@Author JackGao [gx_wanmei@163.com]
     *@Date 2017-6-22 12:13
     *@Description 获取用户信息
     */
    @RequestMapping("/userinfo")
    @ResponseBody
    public User getUser(HttpSession session){
        User user =(User) session.getAttribute("userInfo");
        return user;
    }

    /**
     *@Author JackGao [gx_wanmei@163.com]
     *@Date 2017-6-22 12:31
     *@Description 登出系统
     */
    @RequestMapping("/logout")
    public String logout(HttpSession session){
        session.invalidate();
        return "login";
    }
}
